<?php

namespace App\Http\Controllers\Backend\Api\V1;

use App\Http\Requests\Backend\ClassicCaseRequest;
use App\Services\Gallery\Interfaces\ClassicCaseServiceInterface;
use App\Services\Gallery\Services\ClassicCaseService;
use App\Services\Gallery\Model\ClassicCase;
use App\Services\Gallery\Interfaces\DesignerServiceInterface;
use App\Services\Gallery\Services\DesignerService;
use Illuminate\Http\Request;

class ClassicCaseController extends BaseController
{
    /**
     * @var ClassicCaseService
     */
    protected $classicCaseService;
    /**
     * @var designerService
     */
    protected $designerService;

    public function __construct(ClassicCaseServiceInterface $classicCaseService,DesignerServiceInterface $designerService)
    {
        $this->classicCaseService = $classicCaseService;
        $this->designerService = $designerService;
    }

    public function index(Request $request)
    {
        $classicCases = $this->classicCaseService->index($request->all());
        return $this->successData($classicCases);
    }

    public function create()
    {
        $TypeText = ClassicCase::TYPE_TEXT;
        $designers = $this->designerService->list();
        return $this->successData(compact('TypeText','designers'));
    }

    public function store(ClassicCaseRequest $request)
    {
        $this->classicCaseService->set($request->filldata());
        return $this->success();
    }

    public function edit($id)
    {
        $TypeText = ClassicCase::TYPE_TEXT;
        $classicCase = $this->classicCaseService->get($id);
        $designers = $this->designerService->list();
        return $this->successData(compact('TypeText','classicCase','designers'));
    }

    public function update(ClassicCaseRequest $request, $id)
    {
        $this->classicCaseService->set($request->filldata(), $id);
        return $this->success();
    }

    public function destroy($id)
    {
        $this->classicCaseService->destroy($id);
        return $this->success();
    }
}
